import Vue from "vue";
import "babel-polyfill";
import Cookies from "js-cookie";

import Element from "element-ui";
import "./assets/styles/element-variables.scss";
export const bus = new Vue();

import "@/assets/styles/index.scss"; // global css
import "@/assets/styles/ruoyi.scss"; // ruoyi css
import "@/wss/assets/style/index.scss"; // ruoyi css
import "@/wss/assets/style/global.css";
import App from "./App";
import store from "./store";
import router from "./router";
import directive from "./directive"; //directive
import plugins from "./plugins"; // plugins
// import DictData from '@/components/DictData'

import { getTypeListFn } from "./router";

// DictData.install()

import "./assets/icons"; // icon
import "./permission"; // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { arrTransformObj } from "@/wss/utils/wss.js";
import wssmixin from "@/wss/utils/wss.js";

import {
  parseTime,
  resetForm,
  addDateRange,
  selectDictLabel,
  selectDictLabels,
  download,
  handleTree,
} from "@/utils/ruoyi";
// 分页组件
import Pagination from "@/components/Pagination";
// 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar";
// 富文本组件
import Editor from "@/components/Editor";
// 文件上传组件
import FileUpload from "@/components/FileUpload";
// 图片上传组件
import ImageUpload from "@/components/ImageUpload";
// 字典标签组件
import DictTag from "@/components/DictTag";
// 头部标签组件
import VueMeta from "vue-meta";
// 字典数据组件
import DictData from "@/components/DictData";
// 截图工具
import VueCropper from "vue-cropper";

// 保留两位小数并用逗号分隔
import "@/filters/sumFilters.js";

import { hasHavepermi as $hasHavepermi } from "@/directive/permission/hasHavePermi.js";
// 图标
import "./assets/iconfont/iconfont.css";
import * as filters from "@/filters"; // 自定义过滤器
//webscoket挂载
import WebSocket from "./utils/websocket.js";

Vue.prototype.$WebSocket = new WebSocket(process.env.VUE_APP_BASE_API_WS, 1);
Vue.prototype.$WebSocket2 = new WebSocket(process.env.VUE_APP_BASE_API_WS2, 2);

//腾讯音视频
// import TencentCall from "./utils/tencentCall.js";
// Vue.prototype.$TencentCall = new TencentCall();


/**
 * 名称：插件v-fit-columns
 * 作用：实现element table 列宽自适应
 * 使用： 在 el-table 中添加 v-fit-columns
 */
// import Plugin from 'v-fit-columns';
// Vue.use(Plugin);
import WS from "@/wss/utils/websocket.js";
import detect from "@/utils/cureentAgent.js";
// 全局方法挂载

Vue.prototype.$ws = WS;
Vue.prototype.getDicts = getDicts;
Vue.prototype.getConfigKey = getConfigKey;
Vue.prototype.$bus = bus;

Vue.prototype.$isDevice = detect();

Vue.prototype.parseTime = parseTime;
Vue.prototype.resetForm = resetForm;
Vue.prototype.addDateRange = addDateRange;
Vue.prototype.selectDictLabel = selectDictLabel;
Vue.prototype.selectDictLabels = selectDictLabels;
Vue.prototype.download = download;
Vue.prototype.handleTree = handleTree;
Vue.prototype.$hasHavepermi = $hasHavepermi;
Vue.use(VueCropper);
Vue.use(wssmixin);
Vue.prototype.arrTransformObj = arrTransformObj;
// Vue.prototype.currentStatusFn = currentStatusFn

// 全局组件挂载
Vue.component("DictTag", DictTag);
Vue.component("Pagination", Pagination);
Vue.component("RightToolbar", RightToolbar);
Vue.component("Editor", Editor);
Vue.component("FileUpload", FileUpload);
Vue.component("ImageUpload", ImageUpload);

Vue.use(directive);
Vue.use(plugins);
Vue.use(VueMeta);
DictData.install();
Object.keys(filters).forEach((key) => {
  // 注册自定义过滤器
  Vue.filter(key, filters[key]);
});

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

Vue.use(Element, {
  size: Cookies.get("size") || "medium", // set element-ui default size
});

Vue.config.productionTip = false;

new Vue({
  el: "#app",
  router,
  store,
  render: (h) => h(App),
  // 前台动态路由防止刷新404
  created() {
    // getTypeListFn()
  },
});
